package com.spbdx.common.sensitive;

import cn.hutool.core.util.DesensitizedUtil;

import java.util.function.Function;

/**
 * Description 脫敏类型
 *
 * @author chenwei
 * @version 1.0
 * @date 2023/2/27 9:34
 */
public enum SensitiveType {
    /**
     * 姓名
     */
    USERNAME(str -> DesensitizedUtil.chineseName(str)),
    /**
     * 身份证号
     */
    ID_CARD(str -> DesensitizedUtil.idCardNum(str, 3, 4)),
    /**
     * 手机号
     */
    PHONE(str -> DesensitizedUtil.mobilePhone(str)),
    /**
     * 地址
     */
    ADDRESS(str -> DesensitizedUtil.address(str, 8));

    private final Function<String, String> desensitizer;

    SensitiveType(Function<String, String> desensitizer) {
        this.desensitizer = desensitizer;
    }

    public Function<String, String> getDesensitizer() {
        return desensitizer;
    }
}
